#
#1 0 1 1 2 3 ...
#0 1 1 2 3 5 ...
#

def get_aa(ii):
   ap = [1,0]
   ac = [0,1]
   for i in range(2,ii):
     ap,ac = ac, [ap[0]+ac[0],ap[1]+ac[1]]
     
   if ii == 1:
     return [1,0]
   else:
     return ac

ii,jj,k,ai,aj = list(map(int, input().split()))

if ii > jj:
   ii,jj = jj,ii
   ai,aj = aj,ai

aai = get_aa(ii)
aaj = get_aa(jj)
aak = get_aa(k)

d = [aai + [ai], aaj + [aj]]

dd = d[0][0]*d[1][1] - d[0][1]*d[1][0]
dx = d[0][2]*d[1][1] - d[0][1]*d[1][2]
dy = d[0][0]*d[1][2] - d[0][2]*d[1][0]

a1 = dx // dd
a2 = dy // dd

print(a1 * aak[0] + a2 * aak[1])
